fix(tools): import asyncio in handlers — data-gen errors raised NameError - #13
Open
marekolszewski wants to merge 1 commit into
Open
Conversation
…rror
`_execute_pipeline` guards its body with `except asyncio.CancelledError:`,
but `handlers.py` never imported asyncio — that line was the module's only
reference to the name.
Python evaluates an except clause's expression only when an exception
actually propagates to it, so this stayed invisible on the happy path. On
any failure inside the try block, evaluating `asyncio.CancelledError`
raised `NameError: name 'asyncio' is not defined`, which replaced the real
exception and skipped the `except Exception` handler below it (telemetry +
project-log error recording).
Reproduced with no credentials, where `require_token()` — the second
statement in the try block — raises RuntimeError:
before: NameError: name 'asyncio' is not defined
after: ❌ Pipeline failed: RuntimeError: Not logged in.
Run /login to authenticate with lqh.ai.
`ruff check --select F821` reports no undefined names in handlers.py after
this change, and `pytest tests/unit` passes (1379 passed, 25 skipped).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H8BG6fPGiZjZ8nCB7f9x5h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lqh/tools/handlers.pyusesasyncioon exactly one line —except asyncio.CancelledError:in_execute_pipeline— but never imports it. This adds the missingimport asyncio.Filing directly per CONTRIBUTING's "trivial, mechanical fixes that a reviewer can verify at a glance" — happy to move it to an issue/prompt instead if you'd rather.
Why it matters
Python evaluates an
exceptclause's expression only when an exception actually reaches it, so this stayed invisible on the happy path. But on any failure inside that try block, evaluatingasyncio.CancelledErrorraisesNameError— which replaces the real exception and skips theexcept Exception as e:handler right below it, so the telemetry andproject_logerror recording never run.The try block starts at
handlers.py:1774withload_config()/require_token(), so the most common trigger is simply running data generation while logged out:The intended
CancelledErrorpath (Esc / Ctrl+C mid-generation) was equally affected.Verification
uv run pytest tests/unit→ 1379 passed, 25 skippeduv tool run ruff check . --select F821→ no undefined names remain inhandlers.pyHeads-up, unrelated to this PR
CI's
python lintjob is currently red onmainindependently of this change, so this PR's check will likely come back red too. It's been failing on every push since 2026-07-13 (last green run: 2026-07-10). It began as 2 unused imports; becauseuv tool run ruff check .pins no version and the repo has no[tool.ruff]config, newer ruff defaults have since expanded it to 796 findings. Glad to open a separate issue if useful.